package routes

import (
	v1 "wlblog/src/api/v1"
	"wlblog/src/utils"

	"github.com/gin-gonic/gin"
)

func InitRoute() *gin.Engine {
	gin.SetMode(utils.AppMode)
	r := gin.Default()

	routeV1 := r.Group("api/v1")
	{
		// 登陆路由
		routeV1.POST("login", v1.Login)
		// 用户模块路由
		routeV1.POST("user", v1.AddUser)
		routeV1.GET("user/:id", v1.UserInfo)
		routeV1.GET("user", v1.UserList)
		routeV1.PUT("user/:id", v1.EditUser)
		routeV1.DELETE("user/:id", v1.DelUser)
		// 分类模块路由
		routeV1.POST("category", v1.AddCateory)
		routeV1.GET("category/:id", v1.CateoryInfo)
		routeV1.GET("category/list", v1.CategoryList)
		routeV1.GET("category/articles", v1.ArtsInCategory)
		routeV1.PUT("category/:id", v1.EditCategory)
		routeV1.DELETE("category/:id", v1.DelCategory)
		// 文章模块路由
		routeV1.POST("article", v1.AddArt)
		routeV1.GET("article/:id", v1.ArtInfo)
		routeV1.GET("article/list", v1.ArtList)
		routeV1.PUT("article/:id", v1.EditArt)
		routeV1.DELETE("article/:id", v1.DelArt)
	}
	return r
}
